/**
 * @class Option
 * @fileOverview 信息操作模型
 * @extends yijs.air.Model
 */ 
var Msg = function(){
	this.db = new yijs.air.Db(yijs.config.basePath + yijs.config.dbPath);
	this.table = yijs.config.table.msg;
}
/**
 * 插入数据
 * @return {Boolean}
 */
Msg.prototype.insert = function(data){
	if(data){
		this.db.insert(this.table,data);
	}
	return true;
}
/**
 * 获取指定信息
 * @param {Object} controller 控制器名
 * @param {Object} action     动作名
 */
Msg.prototype.getAssignMsgs = function(controller,action,start,limitNum){
	this.db.where("controller",controller).where("action",action).orderby("created_at","desc").limit(start,limitNum);
	var result = this.db.get(this.table);
	if(result.data && result.data.length > 0){
		return result.data;
	}
	return null;	
}
Msg.prototype.getMsgsNum = function(controller,action){
	this.db.where("controller",controller).where("action",action);
	var result = this.db.get(this.table);
	return result.data && result.data.length || 0;		
}
Msg.prototype.isNull = function(controller,action){
	this.db.where("controller",controller).where("action",action);
	var result = this.db.get(this.table);
	var _bool = true;
	if(result.data && result.data.length > 0){
		return false;
	}
	return _bool;	
}
/**
 * 删除消息
 *  @param {String} name 参数key名
 *  @return {Boolean}
 */
Msg.prototype.delMsgs = function(controller,action){
	this.db.where("controller",controller).where("action",action);
	this.db.del(this.table);
}
/**
 * 更新信息
 * @param {Object} name  key名
 * @param {Object} value 值
 * @return {Boolean}
 */
Msg.prototype.update = function(name,value){

}
